package sample.reflects.factory;

interface fruit{
	public abstract void eat();
}

class Apple implements fruit{

	@Override
	public void eat() {
		System.out.println("Apple");		
	} 
}

class Orange implements fruit{

	@Override
	public void eat() {
		System.out.println("Orange");
	}

}

class Factory{
	public static fruit getInstance(String fuitName){
		fruit f=null;
		if("Apple".equals(fuitName)){
			f=new Apple();
		}
		if("Orange".equals(fuitName)){
			f=new Orange();
		}
		return f;
		
	}
}


public class HelloFruit {
	public static void main(String[]args){
		fruit f=Factory.getInstance("Orange");
		f.eat();
	}

}
